#!/usr/bin/env python3

def main():
    m, n = [int(x) for x in input("请输入M & N: ").split()]
    #  p = [x for x in range(m)]
    p = input("请输入人名,空格为分隔符: ").split()

    print(m, n, p)

    count = 0
    while p:
        o = p.pop(0)
        count += 1
        if count == n:
            print(o)
            count = 0
        else:
            p.append(o)


    #  quit = 0
    #  while quit < m:
        #  index = 0
        #  while index < m:
            #  if p[index] == None:
                #  index += 1
                #  continue

            #  count += 1

            #  if count == n:
                #  print(p[index])
                #  p[index] = None
                #  count = 0
                #  quit += 1

            #  index += 1

if __name__ == "__main__":
    main()
